<?php
namespace Nawa\MedicalCenter;
/**
 * Medical Center Type Object.
 *
 * It represant a type of the MC
 *
 * @author Xavier VILAIN
 * @package Nawa\MedicalCenter
 * @license
 *
 * @property string	$type			Type id (4)
 * @property string	$language		Type language (5)
 * @property string	$label			Label
 * @property bool	$standard		Is a standard type (can't be deleted)
 * @property bool	$active			Is an active type (can be selected)
 * @property bool 	$loekz 			Deletion Flag if true is an been deleted
 */
use Fox\Dao\SqlFragment;
class Type extends \Fox\Object\Versioned {

	/**
	 * Link To Medical Center
	 */
	const LINK_MEDICAL_CENTER = "medicalCenter";

	/**
	 * To standardize the creation/update
	 * @return string label
	 */
	public function label()
	{
		return $this->label;
	}

	/**
	 * Shortcut to get the status
	 * @param string $status
	 * @return string
	 */
	static function labelize($status)
	{
		$info = \Fox\Dao::infos(self::className());
		$query = $info->handle()->createQueryBuilder();
		$query->select('label')
		->from($info->tableName(),'t');
		$fg = new SqlFragment("type = ? AND language = ?",array($status,\Xview::instance()->language()));
		return $fg->pushIn($query)->execute()->fetchColumn();
	}
}
\Fox\Dao::infos(
Type::className(),
new \Fox\Object\Info('medicalcenters_types', \Fox\Databases::DB_APP)
);